import { get, post } from './helpers'

const getAwards = () => {
	const awards = {
		"title": "奖项设置",
		"detail": [{
				"awards": "一等奖",
				"bonus": "1600",
				"number": "1"
			},
			{
				"awards": "二等奖",
				"bonus": "1000",
				"number": "2"
			},
			{
				"awards": "三等奖",
				"bonus": "800",
				"number": "3"
			}
		]
	}
	return awards
}
const getRules = () => {
	const rules = {
		"title": "活动规则",
		"description": [{
				"serial": "1",
				"content": "1.本次活动投票时间从2019年1月24日15:00起至2019年1月24日20:30止；"
			},
			{
				"serial": "2",
				"content": "2.每位员工有一次投票机会，每次只能选择一个节目，且不能投本部门节目；"
			},
			{
				"serial": "3",
				"content": "3.投票结果将于1月24日21:00现场进行公布，奖品不可转让；"
			},
			{
				"serial": "4",
				"content": "4.本次活动最终解释权归荔蜜所有。"
			}
		]
	}
	return rules
}
const getPrograms = ()=>{
	return get('api/getPrograms')
}
const getSms = (phone) => {
	return get('api/getSmsCode?phone=' + phone)
}
const login = (params) => {
	const data = {
		"phone": params.phone,
		"code": params.code
	}
	return post('api/login', data)
}

const voteProgram = (name) => {
	let param = new URLSearchParams()
	param.append('name', name)
	return post('api/voteProgram', param)
}

const getRanking = () => {
	return get('api/findAll')
}

export {
	getAwards,
	getRules,
	getPrograms,
	getUser,
	getSms,
	login,
	voteProgram,
	getRanking
}